<?php
namespace system\core;

use application\Bootstrap;

/**
 * Frontcontroller Hosselaar
 * 
 * @author Steffen Brem <steffenbrem@gmail.com>
 * @package System.core
 */
class Hosselaar 
{
    
    /**
     * Start the application
     */
    public function run() 
    {
        ob_start();
        
        try
        {            
            $this->_setAutoloader();
            $this->_execute();
        }
        catch ( \Exception $e )
        {
            Exception::show($e);
        }
        
        ob_end_flush();
    }
    
    /**
     * Set the autoloader and add autoloading paths
     */
    private function _setAutoloader()
    {
        include SYS_PATH . 'core/Autoloader.php';
        
        spl_autoload_register(array('system\core\Autoloader', 'loadClass'));
        
        // Load neccessary helpers
        include_once SYS_PATH . 'helpers/url_helper.php';
    }
    
    /**
     * Run the application
     */
    private function _execute() 
    {
        Benchmark::start('application');
        
        $router = new Router();
        
        $router->beforeDispatch();
        
        $router->dispatch();
    }
}

/* End of file Hosselaar.php */
